package com.xyz.controller;

import com.xyz.mqtt.MqttSendClient;
import com.xyz.util.dto.DataResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("mqtt")
public class MqttController {
    private static final Logger logger = LoggerFactory.getLogger(MqttController.class);

    @Autowired
    private MqttSendClient mqttSendClient;

    @PostMapping("test")
    public DataResult test() {
        String topic = "LKJHSNGD";
        String sendMessage = "SGLDFKNHJ";
        System.out.println("topic:" + topic);
        System.out.println("message:" + sendMessage);
        mqttSendClient.publish(false, topic, sendMessage);
        return DataResult.build9100("topic:" + topic + "   message:" + sendMessage);
    }

}
